package controller;

import java.awt.Color;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import controller.ActionEvents.ActionHandler;

import model.ModelClass;

import view.AdminPanel;
import view.CenterPanel;
import view.MainFrame;

public class KeyHandler implements KeyListener {
	
	
	private MainFrame frame;
	
	public KeyHandler(MainFrame frame)
	{
		this.frame = frame;
	}

	public void keyPressed(KeyEvent event) {}
	public void keyReleased(KeyEvent event){}

	public void keyTyped(KeyEvent event) 
	{
		ModelClass modelClass = frame.getModelClass();
		CenterPanel centerPanel = frame.getCenterPanel();
		AdminPanel adminPanel = frame.getAdminPanel();
		
		int passwordLength = 0;
		String passwordStrength = null;
		
		if(event.getSource() == adminPanel.getAdminCreateUser().getTextfieldNewUserPassword())
		{
			passwordLength = adminPanel.getAdminCreateUser().getTextfieldNewUserPassword().getText().length();
			
			passwordStrength = modelClass.passwordStrength(passwordLength);

			adminPanel.getAdminCreateUser().getLblSetPasswordStrength().setText(passwordStrength);
		}
		else if(event.getSource() == centerPanel.getAbout().getPasswordFieldNewPw())
		{
			passwordLength = centerPanel.getAbout().getPasswordFieldNewPw().getText().length();
			passwordStrength = modelClass.passwordStrength(passwordLength);
			
			centerPanel.getAbout().getLblSetPasswordStrength().setText(passwordStrength);	
		}
		
		
		
	}

}
